package com.hzlj.position.locate.converter;

import com.fz.common.base.converter.ModelDTOConverter;
import com.fz.common.base.core.date.DateUtils;
import com.hzlj.position.locate.common.dto.abnGathering.AbnGatheringAddDTO;
import com.hzlj.position.locate.common.dto.abnGathering.AbnGatheringQueryResultDTO;
import com.hzlj.position.locate.common.model.AbnGathering;

/**
 * 定位分析-聚众告警表(AbnGathering)DTO转换类
 *
 * @author lifh
 * @date 2023-03-28 10:20:21
 */
public class AbnGatheringConverter {
    /**
     * model实例转换为查询结果DTO
     *
     * @param model model实例
     * @return DTO
     */
    public static AbnGatheringQueryResultDTO from(AbnGathering model) {
        return ModelDTOConverter.from(model, AbnGatheringQueryResultDTO.class);
    }

    /**
     * 新增DTO转换为model实例
     *
     * @param dto 新增DTO
     * @return model实例
     */
    public static AbnGathering from(AbnGatheringAddDTO dto) {
        return ModelDTOConverter.from(dto, AbnGathering.class, (AbnGathering l) -> {
            l.setValid(true);
            l.setUpdateTime(DateUtils.now());
            l.setCreateTime(DateUtils.now());
        });

    }
}
